import 'package:flutter/material.dart';

class Facility {
  final int id;
  final String name;
  final String description;
  final String? createBy;
  final String? createTime;
  final String? updateBy;
  final String? updateTime;
  final String? remark;

  Facility({
    required this.id,
    required this.name,
    required this.description,
    this.createBy,
    this.createTime,
    this.updateBy,
    this.updateTime,
    this.remark,
  });

  factory Facility.fromJson(Map<String, dynamic> json) {
    return Facility(
      id: json['id'] ?? 0,
      name: json['name'] ?? '',
      description: json['description'] ?? '',
      createBy: json['createBy'],
      createTime: json['createTime'],
      updateBy: json['updateBy'],
      updateTime: json['updateTime'],
      remark: json['remark'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'name': name,
      'description': description,
      'createBy': createBy,
      'createTime': createTime,
      'updateBy': updateBy,
      'updateTime': updateTime,
      'remark': remark,
    };
  }

  // 根据设施名称返回对应的图标
  static IconData getIconForFacility(String facilityName) {
    switch (facilityName) {
      case '洗手间':
        return Icons.wc;
      case '停车场':
        return Icons.local_parking;
      case '餐厅':
        return Icons.restaurant;
      case '小卖铺':
        return Icons.store;
      case '自动售货机':
        return Icons.local_drink;
      case '指导钓鱼服务':
        return Icons.school;
      case '休息区':
        return Icons.chair;
      case '烧烤区':
        return Icons.outdoor_grill;
      case '儿童游乐设施':
        return Icons.child_friendly;
      case '麻将桌':
        return Icons.table_restaurant;
      case '露营地':
        return Icons.nature;
      default:
        return Icons.location_on;
    }
  }

  // 根据设施名称返回对应的颜色
  static Color getColorForFacility(String facilityName) {
    switch (facilityName) {
      case '洗手间':
        return Colors.blue;
      case '停车场':
        return Colors.grey;
      case '餐厅':
        return Colors.orange;
      case '小卖铺':
        return Colors.green;
      case '自动售货机':
        return Colors.purple;
      case '指导钓鱼服务':
        return Colors.indigo;
      case '休息区':
        return Colors.brown;
      case '烧烤区':
        return Colors.red;
      case '儿童游乐设施':
        return Colors.pink;
      case '麻将桌':
        return Colors.teal;
      case '露营地':
        return Colors.green;
      default:
        return Colors.grey;
    }
  }

  // 模拟后端数据
  static List<Facility> getMockFacilities() {
    return [
      Facility(id: 1, name: '洗手间', description: '上厕所'),
      Facility(id: 2, name: '停车场', description: '停车的地方'),
      Facility(id: 3, name: '餐厅', description: '吃饭'),
      Facility(id: 4, name: '小卖铺', description: '买东西'),
      Facility(id: 5, name: '自动售货机', description: '自动售货机'),
      Facility(id: 6, name: '指导钓鱼服务', description: '新手必备'),
      Facility(id: 7, name: '休息区', description: '休息一下吧'),
      Facility(id: 8, name: '烧烤区', description: '烧烤'),
      Facility(id: 9, name: '儿童游乐设施', description: '小孩的放松之选'),
      Facility(id: 10, name: '麻将桌', description: '打麻将不'),
      Facility(id: 11, name: '露营地', description: '户外露营'),
    ];
  }
}